﻿Imports NMock2

Imports System.Collections.Generic
Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports Meiners.Libs.Withings
Imports Meiners.Libs.Withings.Core

'''<summary>
'''This is a test class for MeasureTest and is intended
'''to contain all MeasureTest Unit Tests
'''</summary>
<TestClass()> _
Public Class MeasureTest


    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(ByVal value As TestContext)
            testContextInstance = value
        End Set
    End Property

    '''<summary>
    '''A test for Value
    '''</summary>
    <TestMethod()> _
    Public Sub CalculateValueTest()
        Dim expected As Double = 79.3
        Dim actual As Double
        Dim target As Measure = New Measure(79300, -3, MeasureTypeEnum.Weight)
        actual = target.CalculateValue
        Assert.AreEqual(expected, actual)
    End Sub
    '''<summary>
    '''A test for Unit
    '''</summary>
    <TestMethod()> _
    Public Sub UnitTest()
        Dim expected As Integer = 5
        Dim actual As Integer
        Dim target As Measure = New Measure(79.3, expected, MeasureTypeEnum.Weight)
        actual = target.Unit
        Assert.AreEqual(expected, actual)
    End Sub
    '''<summary>
    '''A test for MeasureType
    '''</summary>
    <TestMethod()> _
    Public Sub MeasureTypeTest()
        Dim expected As MeasureTypeEnum = MeasureTypeEnum.FatRation
        Dim actual As MeasureTypeEnum
        Dim target As Measure = New Measure(79300, -3, expected)
        actual = target.MeasureType
        Assert.AreEqual(expected, actual)
    End Sub

    '''<summary>
    '''A test for Measure Constructor
    '''</summary>
    <TestMethod()> _
        Public Sub MeasureConstructorTest()
        Dim target As Measure = New Measure(79300, -1, MeasureTypeEnum.Weight)
        Assert.IsInstanceOfType(target, GetType(Measure), "Instance type check failed")
        Assert.AreEqual(Of MeasureTypeEnum)(MeasureTypeEnum.Weight, target.MeasureType, "default value check for property MEASURETYPE failed")
        Assert.AreEqual(Of Integer)(-1, target.Unit, "default value check for property UNIT failed")
    End Sub

End Class

